<?php 
/**
 * 问题列表
 */

namespace Admin\Controller;
use Hdphp\Library\Controller;

class AskController extends CommonController{

	public function index(){

		$w=isset($_GET['w']) ? intval($_GET['w']) : '';
		switch ($w) {
			case '1':
				$where = " WHERE solve=0";
				break;
			case '2':
				$where = " WHERE solve=1";
				break;
			case '3':
				$where = " WHERE answer=0";
				break;							
			default:
				$where = "";
				break;
		}

		$sql="SELECT * FROM hd_ask {$where}";
		$ask=M()->query($sql);
		$this->assign('ask',$ask);
		$this->assign('totalAsk',count($ask));

		$this->display();
	}

	// 需要关联问题回答内容
	public function del(){
		$asid=intval($_GET['asid']);
		$sql="DELETE FROM hd_ask as a,hd_answer as an WHERE a.asid={$asid} AND a.asid=an.asid ";
		$row=M()->exec("DELETE FROM hd_ask WHERE asid={$asid}");
		if($row){
			$this->error('删除成功');
		}
	}
}

 ?>